<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>

<html>
<head>

    <%@ include file="/common/common.jsp" %>
<title>店铺资料</title>
<link rel="stylesheet" type="text/css" href="../statics/aui/css/aui.css" />
<link rel="stylesheet" type="text/css" href="${ctx }/css/weui.min.css"/>


<style type="text/css">
.receivables_text {
	font-family: PingFangSC-Regular;
	font-size: 15px;
	color: #666666;
	line-height: 30px;
	text-align: right;
}

.father {
	position: fixed;
	width: 100%;
	height: 100%; top; 0;
	left: 0;
	background-color: #FFFFFF;
}

.son {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	width: 50%;
	height: 50%;
	margin: auto;
	background-color: red;
}

.sonlx {
	font-family: PingFangSC-Regular;
	font-size: 13px;
	color: #666666;
	letter-spacing: 0px;
	text-align: center;
}
</style>

</head>
<body class="ui-mobile-viewport ui-overlay-c">

	<div class="aui-content aui-margin-b-15">
		<ul class="aui-list aui-media-list">
			<li class="aui-list-item aui-list-item-middle">
				<div class="aui-media-list-item-inner">
					<div class="aui-list-item-media" style="width: 5rem;">
						<img onerror="this.src='../statics/aui/images/dpmt.png'" src="${ctx}/lookImage?filePath=${merchant.outerImg}" class="aui-img-round aui-list-img-sm">
					</div>
					<div class="aui-list-item-inner">${merchant.shopname }</div>
				</div>
			</li>
		</ul>
	</div>	
	<section class="aui-content">
		<ul class="aui-list">
			<li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">法人姓名</div>
					<div class="aui-list-item-right  ">${merchant.legalName }</div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">商户编号</div>
					<div class="aui-list-item-right  ">${merchant.merchantNo }</div>
				</div>
			</li>
			<li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">所在地区</div>
					<div class="aui-list-item-right  ">${merchant.shopAddress }</div>
				</div>
			</li>
			<%-- <li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">详细地址</div>
					<div class="aui-list-item-right  ">${merchant.userAddress}</div>
				</div>
			</li> --%>

		</ul>
	</section>

	<div>&nbsp;</div>
	<section class="aui-content">
		<ul class="aui-list">
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">联系人</div>
					<div class="aui-list-item-right  ">${merchant.username }</div>
				</div>

			</li>
			<li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">联系电话</div>
					<div class="aui-list-item-right  ">${merchant.mobilephone }</div>
				</div>
			</li>
			<li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">其他联系方式</div>
					<div class="aui-list-item-right  ">${merchant.shopPhone}</div>
				</div>
			</li>
			<li class="aui-list-item  ">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-title receivables_text">联系邮箱(点击修改)</div>
					<div class="aui-list-item-right  ">
						<input id="merchantNo" type="hidden" value="${merchant.merchantNo }">
						<input type="text"  name="email" id="email"  value="${merchant.email }" style="padding-left: -25px;">
					</div>
				</div>
			</li>
			<li  class="aui-list-item" style="margin-top: 20px;margin-bottom: 10px;">
				<div class="aui-list-item-inner" >
					<div class="aui-btn aui-btn-info  aui-btn-block" onclick="saveEmail();">保存</div>
				</div>
			</li>
		</ul>
	</section>
	
	<div class="js_dialog" id="iosDialog2" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__bd" id="DialogMessage"></div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary DeleteDefault">确定</a>
            </div>
        </div>
    </div>

	<div class="sonlx" style="margin-top: 10px;">
		<center>＊如需变更商户资料，请联系客服人员</center>
	</div>
</body>
<script type="text/javascript">
	function saveEmail(){
		var $iosDialog2 = $('#iosDialog2');
		var merchantNo = $('#merchantNo').val();
		var email = $('#email').val();
		
		var search_str = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
		 if(!search_str.test(email)){       
		    
		     $(this).parents('.js_dialog').fadeOut(200);
             $("#DialogMessage").html("邮箱格式不正确");
             $iosDialog2.fadeIn(200);
             
             $(".DeleteDefault").on("click", function () {
                 $(this).parents('.js_dialog').fadeOut(200);
                 $('#email').focus();
             });
             return false;
		 }
		
		$.ajax({
	            type: "POST",
	            url: "../auth/updateEmail",
	            data: {
	            		merchantNo : merchantNo,
	            		email : email
	            		},
	            dataType: "json",
	            success: function (result) {
	                if (result.code == 0) {
	                	$(this).parents('.js_dialog').fadeOut(200);
	                    $("#DialogMessage").html("修改成功");
	                    $iosDialog2.fadeIn(200);
	                }else{
	                	$(this).parents('.js_dialog').fadeOut(200);
	                    $("#DialogMessage").html("修改失败");
	                    $iosDialog2.fadeIn(200);
	                }
	                $(".DeleteDefault").on("click", function () {
                        $(this).parents('.js_dialog').fadeOut(200);
                        location.href = "viewMerInfo";
                    });
	            }
	        });
	}
</script>
</html>